package com.sdry.service.impl.base;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sdry.entity.base.Type;
import com.sdry.entity.base.TypeExample;
import com.sdry.entity.base.TypeExample.Criteria;
import com.sdry.mapper.base.TypeMapper;
import com.sdry.service.base.TypeServise;
import com.sdry.utils.PageBean;

@Service
@Transactional
public class TypeServiseImpl implements TypeServise{

	@Resource
	private TypeMapper typeMapper;
	

	public Type selectByPrimaryKey(Long id) {
		return typeMapper.selectByPrimaryKey(id);
	}

	public Integer insert(Type param) {
		return typeMapper.insert(param);
	}

	public Integer updateByPrimaryKeySelective(Type record) {
		return typeMapper.updateByPrimaryKeySelective(record);
	}

	public Integer delete(String ids) {
		
		int affat = 0;
		
		String[] split = ids.split(",");
		for (String s : split) {
			Long id = Long.valueOf(s);
			affat = typeMapper.deleteByPrimaryKey(id);
		}
		return affat;
	}
	
	public List<Type> selectByExample(Type type) {
		TypeExample example = new TypeExample();
		Criteria createCriteria = example.createCriteria();
		if(type.getTname() != null && type.getTname() != "") {
			createCriteria.andTnameLike("%"+type.getTname()+"%");
		}
		return typeMapper.selectByExample(example );
	}

}
